package com.ruoyi.activitySignLog.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.basciSign.service.IBasicSignService;
import com.ruoyi.basicActivity.domain.RyActivity;
import com.ruoyi.basicActivity.service.IRyActivityService;
import com.ruoyi.basicUser.domain.BasicUser;
import com.ruoyi.basicUser.service.IBasicUserService;
import com.sun.xml.bind.v2.TODO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.activitySignLog.domain.ActivitySignLog;
import com.ruoyi.activitySignLog.service.IActivitySignLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动报名Controller
 * 
 * @author ruoyi
 * @date 2025-10-14
 */
@RestController
@RequestMapping("/activitySignLog/activitySignLog")
public class ActivitySignLogController extends BaseController
{
//    默认活动报名记录--注入
    @Autowired
    private IActivitySignLogService activitySignLogService;
//    活动报名页面--注入活动查询
    @Autowired
    private IRyActivityService ryActivityService;
//    用户列表--注入
    @Autowired
    private IBasicUserService basicUserService ;

    /**
     * 查询活动报名列表
     */
    @PreAuthorize("@ss.hasPermi('activitySignLog:activitySignLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivitySignLog activitySignLog)
    {
        startPage();
        List<ActivitySignLog> list = activitySignLogService.selectActivitySignLogList(activitySignLog);
        return getDataTable(list);
    }

    /**
     * 导出活动报名列表
     */
    @PreAuthorize("@ss.hasPermi('activitySignLog:activitySignLog:export')")
    @Log(title = "活动报名", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivitySignLog activitySignLog)
    {
        List<ActivitySignLog> list = activitySignLogService.selectActivitySignLogList(activitySignLog);
        ExcelUtil<ActivitySignLog> util = new ExcelUtil<ActivitySignLog>(ActivitySignLog.class);
        util.exportExcel(response, list, "活动报名数据");
    }

    /**
     * 获取活动报名详细信息
     */
    @PreAuthorize("@ss.hasPermi('activitySignLog:activitySignLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(activitySignLogService.selectActivitySignLogById(id));
    }

    /**
     * 新增活动报名
     */
    @PreAuthorize("@ss.hasPermi('activitySignLog:activitySignLog:add')")
    @Log(title = "活动报名", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivitySignLog activitySignLog)
    {
        return toAjax(activitySignLogService.insertActivitySignLog(activitySignLog));
    }

    /**
     * 修改活动报名
     */
    @PreAuthorize("@ss.hasPermi('activitySignLog:activitySignLog:edit')")
    @Log(title = "活动报名", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivitySignLog activitySignLog)
    {
        return toAjax(activitySignLogService.updateActivitySignLog(activitySignLog));
    }

    /**
     * 删除活动报名
     */
    @PreAuthorize("@ss.hasPermi('activitySignLog:activitySignLog:remove')")
    @Log(title = "活动报名", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(activitySignLogService.deleteActivitySignLogByIds(ids));
    }



    // TODO 获取活动列表
    /**
     * 查询活动列表
     */
    @RequestMapping("/getActivityList")
    public AjaxResult getActivityList()
    {
        //1.查询活动列表，根据活动记录，查询全部活动
        List<RyActivity> list = ryActivityService.selectRyActivityList(new RyActivity());
        return success(list);
    }


    // TODO 查询用户列表 改为用户相关
    /**
     * 查询用户列表
     */
    @RequestMapping("/getUserList")
    public AjaxResult getUserList()
    {
        //1.查询用户列表，根据用户记录，查询全部用户
        List<BasicUser> lists = basicUserService.selectBasicUserList(new BasicUser());
        return success(lists);
    }





}
